package com.example.mobile2021606185zhn0617;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import androidx.annotation.Nullable;

public class MySQLiteOpenHelper extends SQLiteOpenHelper {
    public MySQLiteOpenHelper(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        String sql = "create table worker("+"_id integer primary key autoincrement,"+"name text not null,"+"skill text not null,"+"money integer)";
        db.execSQL(sql);
        ContentValues contentValues = new ContentValues();
        contentValues.put("name","姓名1");
        contentValues.put("skill","汽车工程师");
        contentValues.put("money",200);
        db.insert("worker", null, contentValues);
        contentValues.put("name","姓名2");
        contentValues.put("skill","汽车工人");
        contentValues.put("money",80);
        db.insert("worker", null, contentValues);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
